package transactionimpl;

import java.sql.SQLException;

import transaction.Transaction;
import util.DBUtil;


public class TransactionImpl implements Transaction{

	public void beginTransaction() {
         try {
			DBUtil.getConnection().setAutoCommit(false);
		} catch (SQLException e) {
			e.printStackTrace();
		}		
	}

	public void commit() {
            try {
				DBUtil.getConnection().commit();
			} catch (SQLException e) {
				e.printStackTrace();
			}finally{
				try {
					DBUtil.closeConnection();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
            
	}

	public void rollback() {
          try {
			DBUtil.getConnection().rollback();
		} catch (SQLException e) {
			e.printStackTrace();
		}finally{
			try {
				DBUtil.closeConnection();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}

}
